package com.qf.mrmd.controller;

import com.qf.mrmd.entity.Order;
import com.qf.mrmd.result.ResponseData;
import com.qf.mrmd.service.OrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Order)表控制层
 *
 * @author makejava
 * @since 2021-07-14 14:41:30
 */
@RestController
@RequestMapping("orders")
public class OrderController {
    /**
     * 服务对象
     */
    @Resource
    private OrderService orderService;

    @ApiOperation(value = "添加预约记录")
    @PostMapping("/")
    public ResponseData saveOrder(@RequestBody Order order){
        return orderService.insert(order);
    }

    @ApiOperation(value = "获取预约记录")
    @GetMapping("/count")
    public ResponseData countOrder(){

        return orderService.countOrder();
    }

    @ApiOperation(value = "获取预约列表")
    @GetMapping("/all")
    public ResponseData getOrderList(Integer page,Integer limit){

        return orderService.queryAllByLimit(page,limit);
    }

    @ApiOperation(value = "更新预约状态")
    @PatchMapping("/")
    public ResponseData updateStatus(@RequestBody Order order){
        return orderService.update(order);
    }

    @ApiOperation(value = "批量删除")
    @DeleteMapping("/")
    public ResponseData deleteBatch(@RequestBody String ids){
        return orderService.deleteBatchById(ids);
    }

    @ApiOperation(value = "模糊查询",notes = "通过项目、商家、用户名称查询")
    @GetMapping("/like")
    public ResponseData queryByLike(Order order,Integer page, Integer limit){

        return orderService.queryByLike(order,page,limit);
    }

}
